*** Replication code for "Multilevel Instruments for Infrastructure Investment: Evaluating State Revolving Funds for Water" ***
*** Mullin and Daley, Policy Studies Journal ***
*** July 2017 ***

*** use MullinDaley_PSJ2017_repfile.dta ***
*** all variables in 2000 $ ***



** 
** Generate per capita variables 
**

sort statecode year
gen title6_totpc=(title6_tot/1000)/population
label var title6_totpc "CW funds awarded per capita"
gen exptot_wspc=exptot_ws/population
label var exptot_wspc "Water supply expenditures per capita" 
gen dwtotpc=(dwtot/1000)/population
label var dwtotpc "DW funds awarded per capita"
gen dwns_totpc=(dwns_tot*1000)/population
label var dwns_totpc "DW needs per capita"
gen exptot_sewpc=exptot_sew/(population)
label var exptot_sewpc "Sewerage expenditures per capita"
gen rev_igfedpc=(rev_igfed/1000)/(population)
label var rev_igfedpc "IG revenue from fed govt per capita"
gen gsppercap=grossstateproduct/(population)
label var gsppercap "GSP per capita"




**
** Analyses for Table 2
**

* Wastewater expenditures
xtpcse d.exptot_sewpc l.title6_totpc d.title6_totpc l.exptot_sewpc l.poplog l.urban l.gsp_pctfarm l.gsp_pctmine l.gsp_pctmanuf l.gsppercap l.rev_igfedpc l.govparty d.poplog  d.urban d.gsp_pctfarm d.gsp_pctmine d.gsp_pctmanuf d.gsppercap d.rev_igfedpc d.govparty cwneed88pc northeast south west i.year

* Drinking water expenditures
xtpcse d.exptot_wspc l.dwtotpc d.dwtotpc l.exptot_wspc l.poplog l.urban l.gsp_pctfarm l.gsp_pctmine l.gsp_pctmanuf l.gsppercap l.rev_igfedpc l.govparty d.poplog  d.urban d.gsp_pctfarm d.gsp_pctmine d.gsp_pctmanuf d.gsppercap d.rev_igfedpc d.govparty northeast south west i.year




**
**  Bewley model for estimating approximate SE of LRM 
**

sort statecode year
tab year, gen(yr)

* Wastewater expenditures
ivreg exptot_sewpc title6_totpc d.title6_totpc poplog  urban gsp_pctfarm gsp_pctmine gsp_pctmanuf gsppercap rev_igfedpc govparty d.poplog  d.urban d.gsp_pctfarm d.gsp_pctmine d.gsp_pctmanuf d.gsppercap d.rev_igfedpc d.govparty cwneed88pc northeast south west yr* ///
(d.exptot_sewpc = l.exptot_sewpc title6_totpc l.title6_totpc poplog  urban gsp_pctfarm gsp_pctmine gsp_pctmanuf gsppercap rev_igfedpc govparty l.poplog  l.urban l.gsp_pctfarm l.gsp_pctmine l.gsp_pctmanuf l.gsppercap l.rev_igfedpc l.govparty cwneed88pc northeast south west), cluster(statecode)

* Drinking water expenditures
ivreg exptot_wspc dwtotpc d.dwtotpc poplog  urban gsp_pctfarm gsp_pctmine gsp_pctmanuf gsppercap rev_igfedpc govparty d.poplog  d.urban d.gsp_pctfarm d.gsp_pctmine d.gsp_pctmanuf d.gsppercap d.rev_igfedpc d.govparty northeast south west yr* ///
(d.exptot_wspc = l.exptot_wspc dwtotpc l.dwtotpc poplog  urban gsp_pctfarm gsp_pctmine gsp_pctmanuf gsppercap rev_igfedpc govparty l.poplog  l.urban l.gsp_pctfarm l.gsp_pctmine l.gsp_pctmanuf l.gsppercap l.rev_igfedpc l.govparty northeast south west), cluster(statecode)




**
** Robustness checks 
** 

* Eliminating outlier: WA in 1993 has sewage capital spending almost 3x the size of any other observation, both in aggregate and per capita 
gen outlie=1 if statename=="Washington" & (year==1993|year==1994)
xtpcse d.exptot_sewpc l.title6_totpc d.title6_totpc l.exptot_sewpc l.poplog l.urban l.gsp_pctfarm l.gsp_pctmine l.gsp_pctmanuf l.gsppercap l.rev_igfedpc l.govparty d.poplog  d.urban d.gsp_pctfarm d.gsp_pctmine d.gsp_pctmanuf d.gsppercap d.rev_igfedpc d.govparty cwneed88pc northeast south west i.year if outlie~=1

* SEs clustered by state
reg d.exptot_sewpc l.title6_totpc d.title6_totpc l.exptot_sewpc l.poplog  l.urban l.gsp_pctfarm l.gsp_pctmine l.gsp_pctmanuf l.gsppercap l.rev_igfedpc l.govparty d.poplog  d.urban d.gsp_pctfarm d.gsp_pctmine d.gsp_pctmanuf d.gsppercap d.rev_igfedpc d.govparty cwneed88pc northeast south west i.year, cluster(statecode)
reg d.exptot_wspc l.dwtotpc d.dwtotpc l.exptot_wspc l.poplog l.urban l.gsp_pctfarm l.gsp_pctmine l.gsp_pctmanuf l.gsppercap l.rev_igfedpc l.govparty d.poplog  d.urban d.gsp_pctfarm d.gsp_pctmine d.gsp_pctmanuf d.gsppercap d.rev_igfedpc d.govparty cwneed88pc northeast south west i.year, cluster(statecode)

* Controlling for total SRF grants instead of year FEs
bysort year: egen popus=sum(population)
bysort year: egen title6_totus=sum(title6_tot)
gen title6_totuspc=(title6_totus/1000)/popus
bysort year: egen dwtotus=sum(dwtot)
gen dwtotuspc=(dwtotus/1000)/popus
sort statecode year
xtpcse d.exptot_sewpc l.title6_totpc d.title6_totpc l.exptot_sewpc l.poplog  l.urban l.gsp_pctfarm l.gsp_pctmine l.gsp_pctmanuf l.gsppercap l.rev_igfedpc l.govparty d.poplog  d.urban d.gsp_pctfarm d.gsp_pctmine d.gsp_pctmanuf d.gsppercap d.rev_igfedpc d.govparty cwneed88pc northeast south west title6_totuspc
xtpcse d.exptot_wspc l.dwtotpc d.dwtotpc l.exptot_wspc l.poplog  l.urban l.gsp_pctfarm l.gsp_pctmine l.gsp_pctmanuf l.gsppercap l.rev_igfedpc l.govparty d.poplog  d.urban d.gsp_pctfarm d.gsp_pctmine d.gsp_pctmanuf d.gsppercap d.rev_igfedpc d.govparty northeast south west dwtotuspc

* Restricting to 1997 and later, when both programs in place
xtpcse d.exptot_sewpc l.title6_totpc d.title6_totpc l.exptot_sewpc l.poplog l.urban l.gsp_pctfarm l.gsp_pctmine l.gsp_pctmanuf l.gsppercap l.rev_igfedpc l.govparty d.poplog  d.urban d.gsp_pctfarm d.gsp_pctmine d.gsp_pctmanuf d.gsppercap d.rev_igfedpc d.govparty cwneed88pc northeast south west i.year if year>1996
xtpcse d.exptot_wspc l.dwtotpc d.dwtotpc l.exptot_wspc l.poplog  l.urban l.gsp_pctfarm l.gsp_pctmine l.gsp_pctmanuf l.gsppercap l.rev_igfedpc l.govparty d.poplog  d.urban d.gsp_pctfarm d.gsp_pctmine d.gsp_pctmanuf d.gsppercap d.rev_igfedpc d.govparty northeast south west i.year if year>1996

* Drinking water need as control and as instrument
xtpcse d.exptot_wspc l.dwtotpc d.dwtotpc l.exptot_wspc l.poplog  l.urban l.gsp_pctfarm l.gsp_pctmine l.gsp_pctmanuf l.gsppercap l.rev_igfedpc l.govparty d.poplog  d.urban d.gsp_pctfarm d.gsp_pctmine d.gsp_pctmanuf d.gsppercap d.rev_igfedpc d.govparty northeast south west dwns_totpc i.year
ivreg d.exptot_wspc l.exptot_wspc d.dwtotpc l.poplog  l.urban l.gsp_pctfarm l.gsp_pctmine l.gsp_pctmanuf l.gsppercap l.rev_igfedpc l.govparty d.poplog  d.urban d.gsp_pctfarm d.gsp_pctmine d.gsp_pctmanuf d.gsppercap d.rev_igfedpc d.govparty northeast south west yr* (l.dwtotpc = l.dwns_totpc l.poplog), cluster(statecode) first

* Including discretionary Title 2 and STAG funds
sort statecode year
gen title2pc=(title2/1000)/population
gen stagcw_sppc = stagcw_split/(population)
gen stagdw_sppc = stagdw_split/(population)
xtpcse d.exptot_sewpc l.title6_totpc d.title6_totpc l.title2pc d.title2pc l.stagcw_sppc d.stagcw_sppc l.exptot_sewpc l.poplog l.urban l.gsp_pctfarm l.gsp_pctmine l.gsp_pctmanuf l.gsppercap l.rev_igfedpc l.govparty d.poplog  d.urban d.gsp_pctfarm d.gsp_pctmine d.gsp_pctmanuf d.gsppercap d.rev_igfedpc d.govparty cwneed88pc northeast south west i.year
xtpcse d.exptot_wspc l.dwtotpc d.dwtotpc l.stagdw_sppc d.stagdw_sppc l.exptot_wspc l.poplog l.urban l.gsp_pctfarm l.gsp_pctmine l.gsp_pctmanuf l.gsppercap l.rev_igfedpc l.govparty d.poplog  d.urban d.gsp_pctfarm d.gsp_pctmine d.gsp_pctmanuf d.gsppercap d.rev_igfedpc d.govparty northeast south west dwns_totpc i.year




**
** Figure 1: SRF capitalization grants 
**

graph twoway line title6_totus year if year<2009 & year>1988, sort clpattern(solid) clcolor(black) || ///
line dwtotus year if year<2009 & year>1997, sort clpattern(dash) clcolor(black) ||, ///
xtitle("") ytitle("Millions of Real (2000) Dollars", margin(medsmall)) ///
ylabel(0 500000000 "$500" 1000000000 "$1,000" 1500000000 "$1,500" 2000000000 "$2,000" 2500000000 "$2,500", angle(horizontal)) ///
legend(label(1 "CWSRF") label(2 "DWSRF")) scheme(s1mono)




